//
//  CustomBarViewController.m
//  FMSManagerDemo
//
//  Created by hongbao.cui on 14-12-15.
//  Copyright (c) 2014年 hongbao.cui. All rights reserved.
//

#import "CustomBarViewController.h"
#import "ApplicationUtils.h"
@interface CustomBarViewController ()

@end

@implementation CustomBarViewController
-(void)backBtnClicked:(id)sender{
    [self dismissViewControllerAnimated:YES completion:^{
        
    }];
}
-(void)rightBtnClicked:(id)sender{
    [self dismissViewControllerAnimated:YES completion:^{
        
    }];
}
-(void)initNaviBar{
    UIImage *topImage = [[ApplicationUtils getLocalImage:@"Navigation-Bar_backgroud_44@2x"] resizableImageWithCapInsets:UIEdgeInsetsMake(5, 5, 5, 5)];
    UIImageView *bgBar = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, FMScreenWidth, FMStatuesHeight+FMNavHeight)];
    [bgBar setImage:topImage];
    [self.view addSubview:bgBar];
    
    UIImage *back = [ApplicationUtils getLocalImage:@"Navigation-Bar_Return_btn_@2x"];
    UIButton *backBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [backBtn setBackgroundImage:back forState:UIControlStateNormal];
    [backBtn setBackgroundImage:back forState:UIControlStateHighlighted];
    [backBtn setFrame:CGRectMake(10, 20+21.0/2, 23.0, 23.0)];
    [backBtn addTarget:self action:@selector(backBtnClicked:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:backBtn];
    
    _titleLabel = [[UILabel alloc] initWithFrame:CGRectMake((FMScreenWidth-100)/2, 20, 100, FMNavHeight)];
    [_titleLabel setText:@""];
    [_titleLabel setTextColor:[UIColor whiteColor]];
    [_titleLabel setTextAlignment:NSTextAlignmentCenter];
    [self.view addSubview:_titleLabel];
    
//    UIImage *rightImage = [ApplicationUtils getLocalImage:@"Navigation-Bar_Return_btn_@2x"];
    UIButton *rightBtn = [UIButton buttonWithType:UIButtonTypeCustom];
//    [rightBtn setBackgroundImage:rightImage forState:UIControlStateNormal];
//    [rightBtn setBackgroundImage:rightImage forState:UIControlStateHighlighted];
    [rightBtn setFrame:CGRectMake(FMScreenWidth-54, 20+21.0/2, 44.0, 23.0)];
    [rightBtn setTitle:@"提交" forState:UIControlStateNormal];
    [rightBtn setTitle:@"提交" forState:UIControlStateHighlighted];
    [rightBtn addTarget:self action:@selector(rightBtnClicked:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:rightBtn];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self initNaviBar];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
-(void)dealloc{
    _titleLabel = nil;
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/
@end
